Q: My fonts won't work with the appkit! What can I do?\
\
A: Yikes!! This is not an easy question to answer, as fonts are very complicated and any number of things can be wrong. However, there are many things you can do to narrow down the scope of the problem.\
\
There are a couple of ways in which a malformed or mis-installed PostScript font manifests itself. Sometimes the font name simply doesn't appear in the font panel of an application. Sometimes the new font name does appear, but when selected the display reads:\
\
\f3\fs24 <<Unusable Font>>\
\f0\fs28 \
And sometimes when a font is selected and previewed within the font panel, the name of the font will appear in the display, but it will look exactly like your default font (as a matter of fact it will be displayed in your default font). In this case, if you look in the console, you will likely see error messages which look like this:\
\
\pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs20\fc0 Feb 15 12:36:57 me Edit[13537]: DPS client library error: PostScript program error, DPSContext 48160\
Feb 15 12:36:58 me Edit[13537]: %%[ Error: typecheck; OffendingCommand: setshared ]%%\
Feb 15 12:36:58 me Edit[13537]: DPS client library error: PostScript program error, DPSContext 48160\
Feb 15 12:36:58 me Edit[13537]: %%[ Error: typecheck; OffendingCommand: setfont ]%%\
\
\f0\fs28 So, how do you fix it?\
\
First, there is a bug in the appkit which may cause the erroneous
\f3\fs24 <<unusable font >>
\f0\fs28 message. So the first thing that you should do when debugging a newly installed font is to make sure that you are not encountering this bug.\
\
The following steps will cause the bug:\
\
• Add a font to
\b ~/Library/Fonts
\b0 (or
\b /LocalLibrary/Fonts
\b0 ).\
• In a shell, run
\b buildafmdir
\b0 on that directory.\
\
There are a couple of other dependencies, but in general the new font will be
\f3\fs24 <<unusable>>
\f0\fs28 . A power-cycle will not fix this—the directory is in a bad state. The user level work-around is:\
\
\fi-800\li800 • Move a font out of the directory. Then move it back in (thus updating the modified time of the directory).\
• Remove the
\b .afmcache
\b0 ,
\b .fontdirectory
\b0 , and
\b .fontlist
\b0 files from the font directory.\
• Launch an application with a Font Panel. Bring up the Font Panel. You should get an alert saying "Incorporating info about new fonts...". All correct fonts in the directory should now be usable.\
\fi0\li0 \
The underlying cause here is that in Release 2 there are two programs that are run on the font directory:
\b buildafmdir
\b0 (which creates
\b .fontdirectory
\b0 and
\b .fontlist
\b0 ) and
\b cacheAFMData
\b0 (which creates
\b .afmcache
\b0 ). When you let the kit notice that there are new fonts, it does the right thing and runs both. If you just run
\b buildafmdir
\b0 by hand, you will sometimes screw up the caching of the AFM data.
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 The only reason
\pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 s
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 you
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28\fc0 You may not get the alert saying "Incorporating info about new fonts..." immediately after launching an application. This is because the appkit discovers new fonts lazily. For applications that use the FontManager when they launch, new fonts are incorporated at launch. For other applications, it won't happen until you bring up the Font Panel. Bringing up the Font Panel will always do it.\
\
\pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 The best way to install a font is to just copy it into a font directory. In fact, it may also be best to remove
\b .fontdirectory
\b0 ,
\b .fontlist
\b0 , and
\b .afmcache
\b0 after installing a new font, and launching a new application.\
\
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 Once you have verified that the Workspace Manager has properly recognized the newly installed font, you should determine whether or not the problems that you are having lie with the installation of the font. A font—let's call it
\b Scrabble
\b0 —should have the following file system structure: there should be
\i at least
\i0 these three directories in
\b ~/Library/Fonts
\b0 , or
\b /NeXTLibrary/Fonts
\b0 or
\b /LocalLibrary/Fonts
\b0 :\
\b Scrabble.font
\b0 \
\b afm
\b0 \
\b outline
\b0 \
(If any font contains bitmap fonts, then a
\b bitmap
\b0 directory is required as well.) The
\b Scrabble.font
\b0 directory must contain all of the files which describe the font:
\b Scrabble and Scrabble.afm
\b0 .
\pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 Any release 2 software (2.0, 2.1,...) uses the PostScript outline, .afm
\pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\fc0 and .bepf files out of the containing .font directory, whereas the 1.0 software requires sym
\b0 contains the PostScript program which describes the outline of each individual character. The file
\b Scrabble.afm
\b0 contains the width information for each character. Both the outline file and the afm file contain the name of the font, and the font family among other information about the font. The file names
\i must
\i0 match the font names which appear within the files.\
\
Taking our Scrabble example, in the Scrabble file we should see the following entries:\
The names change a little bit when you consider that many font families will provide both bold and italic versions. Here's how a bold version of the Scrabble font would look:\
It is important that the FullName be the FamilyName followed by whatever you want to appear in the second (Typeface) browser of the FontPanel. In the above example, the word "Scrabble" would appear in the Family browser in the FontPanel and the word "Bold" will appear in the Typeface browser. If the FullName of the font is exactly equal to the FamilyName, then the word that appears in the second column will be the value of the Weight field in the afm file. (This would have been the case for the example "FullName Scrabble" above.)\
\
And finally, on 1.0 you must link these files into the afm and outline directories. Use the following commands to do that:\
\
\pard\tx620\tx1240\tx1860\tx2480\tx3100\tx3720\tx4340\tx4980\tx5600\tx6220\f3\fs24 % cd ~/Library/Fonts/afm\
If your font contains bitmap files, you must link those files into the bitmap directory.\
\
Once you think that you have your fonts in order,
\fc0 you will have to re-launch an application (and bring up the Font Panel) to take advantage of the new fonts. When an application is launched, the appkit can detect that new fonts have been added to the directory, and it runs
\b buildafmdir
\b0 and
\b cacheAFMdata
\b0 , as described above. \
\
Once you have correctly installed the font, there may still be some problems. Now, you must determine whether the problem lies within the PostScript outline file or with the afm file. The manner in which the font fails can sometime indicate which is the guilty party. If you are receiving an error in the font panel says the font is unusable, then the afm file is guilty.\
\
Another way to determine whether the fault is with the outline file or with the afm file is to run the outline file through
\b pft
\b0 .\
\
Here's how to do that (the commands that you type are in bold):\
You may have noticed that the full pathname of the font's outline file is required.
\b
\b0 The command
\b pft
\b0 merely opens a connection to the window server, which has been running since you booted up your machine. The window server is always launched from the root directory, and you must give the pathname from the current directory of the window server, not your current directory.\
\
In the above
\b pft
\b0 session the outline file had a syntax error in it, and the PostScript interpreter could not process it, producing an error. Of course, since PostScript error handling is archaic and does not inform you of the problem and where it exists, you must take further steps to discover just where that problem is. If you have it, you can use the DisplayTalk application to trace through the PostScript code, and it will identify the line on which the error occurs. Otherwise, you must resort to brute force method of debugging such as printing statements, and removing parts of the code a little bit at a time.\
\
While you are still connected to
\b pft
\b0 you can look at the values of the font dictionary to see if things are as they should be. Refer to the Red Book (the PostScript Language Reference Manual) for more information on the structure of the font dictionary. Remember also that fonts are stored in the FontDirectory in the PostScript interpreter.\
\
Some common problems to look for when debugging your fonts:\
\
• Check for strange characters like <ctrl-Z> or <ctrl-D> characters at the end of the outline file. Often in the PC or MacIntosh world these characters are used to indicate end-of-job to the printer. However, it's not part of the PostScript language; it's really a printer protocol, and doesn't belong in a PostScript program.\
\
• Also, make sure that the carriage returns in the files are indeed carriage returns and not line feeds. Again, this is caused from the difference between file formats on a PC or MacIntosh and those on UNIX.\
\
• Since these files are ASCII and partially human-readable, you can look at the files. Sometimes just by looking at the files carefully, you will notice something that doesn't look right, and which will indeed be the problem. Check to make sure that entries are consistently capitalized. For example, if you saw the following:\
\
\f3\fs24 FullName Scrabble\
FamilyName Scrabble\
weight standard\
Notice \
ItalicAngle 0.0\
\f0\fs28 \
There's a big clue that the weight entry is incorrect.\
\
• The Weight entry has a discrete set of valid values. They are "Ultra Light", "Thin", "Light", "Extra Light", "Book", "Regular", "Plain", "Roman", "Medium", "Demi", "Demi-Bold", "Semi-Bold", "Bold", "Extra Bold", "Heavy", "Heavyface", "Black", "Ultra", "UltraBlack", "Fat", "ExtraBlack", and "Obese".\